//Debugger Window Class Source File
//Debugger Window for use with Debugging

	//Include Files//
#include "Debugger.hpp"

	//Globals & Constants//

/**********************************************************************************************************************\
|	Default Constructor:																							   |
\**********************************************************************************************************************/
Debugger::Debugger()
{

}	//End Debugger()

/**********************************************************************************************************************\
|	Copy Constructor:																								   |
\**********************************************************************************************************************/
Debugger::Debugger(const Debugger& Input)
{

}	//End Debugger(Debugger)

/**********************************************************************************************************************\
|	Get Instance:  Returns an instance of the Debugger for Singleton Pattern										   |
\**********************************************************************************************************************/
Debugger& Debugger::GetInstance()
{
	//if(m_pInstance == NULL)
	//{
	//	m_pInstance = new Debugger();
	//}	//End if(instance == NULL)

	static Debugger Instance;

	return Instance;
}	//End Instance()

/**********************************************************************************************************************\
|	Destructor:																										   |
\**********************************************************************************************************************/
Debugger::~Debugger()
{
	Exit();
}	//End ~Debugger()

/**********************************************************************************************************************\
|	Init:																											   |
\**********************************************************************************************************************/
void Debugger::Init(char* WindowTitle)
{
	AllocConsole();
	SetConsoleTitle(WindowTitle);
	m_Handle = GetStdHandle(STD_OUTPUT_HANDLE);
}	//End Init()

/**********************************************************************************************************************\
|	Exit:																											   |
\**********************************************************************************************************************/
void Debugger::Exit()
{
	FreeConsole();
	
	//if(m_pInstance != NULL)
	//{
	//	delete m_pInstance;
	//	m_pInstance = NULL;
	//}
}	//End Exit()

/**********************************************************************************************************************\
|	EndLine:																											   |
\**********************************************************************************************************************/
void Debugger::EndLine()
{
	WriteConsole(m_Handle, "\n", 1, NULL, NULL);
}	//End EndLine()

/**********************************************************************************************************************\
|	PrintString:																											   |
\**********************************************************************************************************************/
void Debugger::PrintString(char* Message)
{
		//Set Text Color to WHITE//
	SetConsoleTextAttribute(m_Handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);

	WriteConsole(m_Handle, Message, strlen(Message), NULL, NULL);
	EndLine();
}	//End PrintString()

/**********************************************************************************************************************\
|	PrintError:																											   |
\**********************************************************************************************************************/
void Debugger::PrintError(char* File, int Line, char* Function)
{
		//Set Text Color to RED//
	SetConsoleTextAttribute(m_Handle, FOREGROUND_RED | FOREGROUND_INTENSITY);
	
	char buffer[16];
	_itoa_s(Line, buffer, 10);
	
	WriteConsole(m_Handle, "File: ", 6, NULL, NULL);
	WriteConsole(m_Handle, File, strlen(File), NULL, NULL);
	EndLine();
	WriteConsole(m_Handle, "Line: ", 6, NULL, NULL);
	WriteConsole(m_Handle, buffer, strlen(buffer), NULL, NULL);
	WriteConsole(m_Handle, "      Function: ", 16, NULL, NULL);
	WriteConsole(m_Handle, Function, strlen(Function), NULL, NULL);
	EndLine();
}	//End PrintError()